/*
 * $Id: IIPVersionConnInfoDAO.java,v 1.4 2009/07/29 17:22:59 oliver Exp $
 * 
 * Copyright (C) 2006 General Electric Company. All Rights Reserved.
 * 
 * This software is the confidential and proprietary information of the General
 * Electric Company (GE). You shall not disclose this software and shall use it
 * only in accordance with the terms of the license agreement you entered into
 * with GE.
 * 
 * GE MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
 * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
 * NON-INFRINGEMENT. GE SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE
 * AS A RESULT OF USING, MODIFYING, OR DISTRIBUTING THIS SOFTWARE OR ITS
 * DERIVATIVES.
 */
package com.ge.healthcare.autosc.common.database.dao;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.ge.healthcare.autosc.common.ASCUtil;
import com.ge.healthcare.autosc.common.database.pojo.CfgIipVersionConnInfo;

/**
 * @author 212042764
 * 
 */
public class IIPVersionConnInfoDAO extends BaseDAO implements
		IIIPVersionConnInfoDAO {
	/**
	 * Eclispe generated
	 */
	private static final long serialVersionUID = 6655118018156499380L;

	

	protected IIPVersionConnInfoDAO() {
		super(CfgIipVersionConnInfo.TABLE_NAME);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @seecom.ge.healthcare.autosc.common.database.dao.IIIPVersionConnInfoDAO#
	 * getIIPInfoByModelType(java.lang.String)
	 */
	public CfgIipVersionConnInfo getIIPInfoByModelType(String modelType) {
		if (ASCUtil.isNullOrEmpty(modelType)) {
			return null;
		}
		return (CfgIipVersionConnInfo) findObjectByID(CfgIipVersionConnInfo.COL_MODEL_TYPE, modelType);
	}

	public CfgIipVersionConnInfo getIIPInfoForOnWatchModelType(String modelType) {
		if (ASCUtil.isNullOrEmpty(modelType)) {
			return null;
		}
		Map<String, Object> whereClause = new HashMap<String, Object>();
		whereClause.put(CfgIipVersionConnInfo.COL_MODEL_TYPE, modelType);
		whereClause.put("upper(" + CfgIipVersionConnInfo.COL_CONN_TYPE + ")", CfgIipVersionConnInfo.CONN_TYPE_ONWATCH.toUpperCase());
		List<?> rtvdResults = findByProperties(whereClause);
		if (ASCUtil.isNullOrEmptyList(rtvdResults)) {
			return null;
		}
		return (CfgIipVersionConnInfo) rtvdResults.get(0);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @seecom.ge.healthcare.autosc.common.database.dao.IIIPVersionConnInfoDAO#
	 * saveAlways(java.lang.Object)
	 */
	public void saveAlways(Object pojo) {
		super.save(pojo);
	}

}
